﻿using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace HgAdapter
{
	public class HgAdd : HgCommand
	{
		public void Run(List<string> fileToAddFullFileNames)
		{
			string fileNames = string.Empty;

			string saveCurrentDirectory = Environment.CurrentDirectory;
			Environment.CurrentDirectory = ProjectCommitInfo.Instance.ProjectPath;

			foreach (string fileToAddFullFileName in fileToAddFullFileNames)
			{
				fileNames += "\"" + fileToAddFullFileName + "\" ";
			}
			
			Process hgProcess = Process.Start(HgStatusStartInfo("add " + fileNames));
			hgProcess.WaitForExit();

			Environment.CurrentDirectory = saveCurrentDirectory;
		}
	}
}
